package com.controller;

import com.pojo.SomeClass;
import com.service.SomeClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.awt.print.Pageable;
import java.util.List;

@CrossOrigin
@Controller
@RequestMapping("/class")
public class SomeClassController {
    @Autowired
    SomeClassService someClassService;

    public static final int PAGE_SIZE = 8;

    @GetMapping("/findAll")
    public @ResponseBody List<SomeClass> findAll(){
        return someClassService.findAll();
    }

    @GetMapping("/selectFindAll")
    public @ResponseBody List<SomeClass> selectFindAll(Integer page){
        int startRow = 0;
        if(page != null){
            startRow = (page-1)*PAGE_SIZE;
        }
        return someClassService.selectFindAll(startRow,PAGE_SIZE);
    }

    @GetMapping("/getCount")
    public @ResponseBody int getCount(){
        return someClassService.getCount();
    }

    @RequestMapping("/getInsert")
    public @ResponseBody int getInsert(@RequestBody SomeClass record){
        return someClassService.insert(record);
    }


}
